<?php

/**
 * This is the model class for table "tim".
 *
 * The followings are the available columns in table 'tim':
 * @property integer $id_tim
 * @property integer $id_kegiatan
 * @property integer $id_kary
 * @property integer $id_transport
 * @property integer $id_provinsi
 * @property string $no_spd
 * @property double $biaya_trans
 * @property double $airportax
 * @property double $riil
 * @property string $tgl_mulai
 * @property string $tgl_berakhir
 * @property string $descrip_tim
 *
 * The followings are the available model relations:
 * @property Kegiatan $idKegiatan
 * @property Karyawan $idKary
 * @property Provinsi $idProvinsi
 * @property Transport $idTransport
 */
class Tim extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Tim the static model class
	 */
	public $nip,$nama,$nama_kegiatan,$description,$nama_prov,$biaya_harian,$biaya_penginapan,$hari;
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tim';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('id_kegiatan, id_kary, id_transport, id_provinsi, biaya_trans, tgl_mulai, tgl_berakhir', 'required'),
			array('id_kegiatan, id_kary, id_transport, id_provinsi', 'numerical', 'integerOnly'=>true),
			array('biaya_trans, airportax, riil', 'numerical'),
			array('no_spd', 'length', 'max'=>50),
			array('descrip_tim', 'safe'),
			array('nip,nama,nama_kegiatan,description,nama_prov,biaya_harian,biaya_penginapan,hari', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id_tim, id_kegiatan, id_kary, id_transport, id_provinsi, no_spd, biaya_trans, airportax, riil, tgl_mulai, tgl_berakhir, descrip_tim', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'idKegiatan' => array(self::BELONGS_TO, 'Kegiatan', 'id_kegiatan'),
			'idKary' => array(self::BELONGS_TO, 'Karyawan', 'id_kary'),
			'idProvinsi' => array(self::BELONGS_TO, 'Provinsi', 'id_provinsi'),
			'idTransport' => array(self::BELONGS_TO, 'Transport', 'id_transport'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id_tim' => 'Id Tim',
			'id_kegiatan' => 'Id Kegiatan',
			'id_kary' => 'Id Kary',
			'id_transport' => 'Id Transport',
			'id_provinsi' => 'Provinsi',
			'no_spd' => 'No Spd',
			'biaya_trans' => 'Biaya Trans',
			'airportax' => 'Airportax',
			'riil' => 'Riil',
			'tgl_mulai' => 'Tgl Mulai',
			'tgl_berakhir' => 'Tgl Berakhir',
			'descrip_tim' => 'Descrip Tim',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id_tim',$this->id_tim);
		$criteria->compare('id_kegiatan',$this->id_kegiatan);
		$criteria->compare('id_kary',$this->id_kary);
		$criteria->compare('id_transport',$this->id_transport);
		$criteria->compare('id_provinsi',$this->id_provinsi);
		$criteria->compare('no_spd',$this->no_spd,true);
		$criteria->compare('biaya_trans',$this->biaya_trans);
		$criteria->compare('airportax',$this->airportax);
		$criteria->compare('riil',$this->riil);
		$criteria->compare('tgl_mulai',$this->tgl_mulai,true);
		$criteria->compare('tgl_berakhir',$this->tgl_berakhir,true);
		$criteria->compare('descrip_tim',$this->descrip_tim,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}